package com.oss.mq.service.impl;

import com.oss.mq.mapper.ServiceMonitorMapper;
import com.oss.mq.entity.pojo.ServiceMonitor;
import com.oss.mq.service.IServiceMonitorService;
import com.oss.mq.utils.SnowflakeUtils;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * Author yaoyaoyao
 * Date 2024/7/17 15:23
 */
@Service
public class ServiceMonitorServiceImpl implements IServiceMonitorService {
    @Resource
    ServiceMonitorMapper monitorMapper;
    @Override
    public Integer addMonitor(ServiceMonitor monitor) {
        monitor.setMonitorId(SnowflakeUtils.generate()).setCreateDate(new Date())
                .setIsValid("Y").setCreateUser(1).setModifyUser(1)
                .setModifyDate(new Date());
        return monitorMapper.insertSelective(monitor);
    }

    @Override
    public void deleteMonitor(Long id) {
        monitorMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void modifyMonitor(ServiceMonitor monitor) {
        monitor.setModifyUser(1).setModifyDate(new Date());
        monitorMapper.updateByPrimaryKeySelective(monitor);
    }

    @Override
    public List<ServiceMonitor> selectMonitor() {
        return null;
    }
}
